package com.xspace.android.xafcommon.view;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;

/**
 * 自定义MyRecyclerView，解决ListView中嵌套MyRecyclerView显示不正常的问题
 *
 */
public class MyRecyclerView extends RecyclerView {
    public MyRecyclerView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public MyRecyclerView(Context context) {
        super(context);
    }

    public MyRecyclerView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

//    @Override
//    public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
//        int maxHeight = 0;
//        int count = getChildCount();
//        int multiple = count / 4;
//        int remainder = count % 4;
//        if (remainder != 0) {
//            multiple++;
//        }
//        if (count > 0) {
//            View child = getChildAt(0);
//            RecyclerView.LayoutParams params = (LayoutParams) child.getLayoutParams();
//            child.measure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
//            maxHeight = child.getMeasuredHeight() + getPaddingTop() + getPaddingBottom() + params.topMargin + params
//                    .bottomMargin;
//            maxHeight *= multiple;
//        }
//        super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(maxHeight, MeasureSpec.EXACTLY));
////        int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
////        super.onMeasure(widthMeasureSpec, expandSpec);
//    }
}